/**
 * 客户资料维护 - 同步ERP结果
 * @author miaoyl
 * @date 2018/01/14
 */
define(function () {

    var self,
        doc = document,
        app = win.app,
        layui = win.layui,
        element,
        table,
        table_where = {},
        cols = [[
            {field: 'SYNCRESULT', width: 160, title: '同步成功否'}
            , {field: 'GWAK001', width: 140, title: '客户编号'}
            , {field: 'GWAKL003', width: 140, title: '客户名称'}
            , {field: 'MB002', width: 140, title: 'ERP公司'}
            , {field: 'REMARK', width: 140, title: '原因'}
        ]],
        table_data = []
    ;

    var Gwai300ErpResult = app.Module.extend({
        init: function () {
            self = this;
            self._super({
                _tag: 'gwai300_syncERP_result',
            }, win);
        },

        _call:function (obj) {
            table_data = obj.list;
            self._reloadTable({id:'gwai300_syncERP_result_table',data : table_data});
        },

        initTable: function () {
            layui.use(['table'], function () {
                table = layui.table;
                table.render({
                    elem: app.getByid(doc, 'gwai300_syncERP_result_table'),
                    data:table_data,
                    id: 'gwai300_syncERP_result_table',
                    size: _layuiConfig.ui_size,
                    autoSort: false, //禁用前端自动排序
                    height: 'full-200',
                    cols: cols,
                    loading: true,
                    page: true,
                    where: table_where,
                    done: function (res, curr, count) {

                    }
                });

                var tipsIndex = null;

                $(doc).on('click', function () {
                    tipsIndex && layer.close(tipsIndex);
                });

            });
        },

        _ready: function () {
            var vue = new Vue({
                el: '#gwai300_syncERP_result',
                data: '',
                methods: {
                    cancel:function () {
                        layer.close(layer.index);
                    },
                    sure:function () {

                    }
                },
                created: function () {
                    self._setEleIsReady('gwai300_syncERP_result');
                }
            });

            self.initTable();
        },
        _lazy: function () {
            this._super();
            layui.use(['table'], function () {
                element = layui.element;
            });
        }
    });

    return new Gwai300ErpResult();

});